#coding gb2312
a = 'Python programs'
b = 'study Python programming'

for i in [1, 2, 3, 4, 5]:
    print(a)

# input('程序结束，按【Enter】键退出！')
x = 200
if x > 100:
    print(b)
else:
    print(a)


age_1 = 22 

age_2 = 18

print(age_1 >=21 and age_2 < 17)

age_2 = 16

print(age_1 >=21 and age_2 < 17)

print(age_2 < 20 or age_2 < 17)

for value in range(1, 10):
    print(value)

listNum = list(range(1, 19))
print(listNum)

age = 16

if age < 4:
    print('cost 4')
elif age < 10:
    print('cost 10')

elif age < 17:
    print('cost 17')

else:
    print('cost 20')


requested_toppings = []

if requested_toppings:
    for requested_topping in requested_toppings:
        print('Adding ' + requested_toppings + '.')
    print("Finished making your pizza")
else:
    print('Are you sure want a plain pizza?')


alien_0 = {'color': 'green', 'points': 5}
# print(alien_0['points'])
# print('You just earned ' + str(alien_0['points']) + ' points!')

alien_0['x_position'] = 10
alien_0['y_position'] = 30

print(alien_0)

alien_1 = alien_0

alien_1['z_position'] = 30

print(alien_0)

alien_2 = { 'x_position': 0, 'y_position': 25, 'speed': 'medium' }
print("Original x-postion: " + str(alien_2['x_position']))

if alien_2['speed'] == 'slow':
    x_increment = 1
elif alien_2['speed'] == 'medium':
    x_increment = 2
else:
    x_increment = 3

alien_2['x_position'] = alien_2['x_position'] + x_increment

print('New x-position: ' + str(alien_2['x_position']))

users = { 'userName': 'efermi', 'firstName': 'enrico', 'lastName': 'fermi'}
# 遍历字典中的所有key和value
for key, value in users.items():
    print('\nKey: ' + str(key))
    print('Value: ' + str(value))
# 遍历字典中的所有key和value
for k, v in users.items():
    print('\nKey: ' + str(k))
# 遍历字典中的所有key值
for k in users.keys():
    print(str(k) + '---')

favorite_languages = {'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'java'}
for name, language in favorite_languages.items():
    print(str(name.title()) + "'s favorite language is " + str(language.title()) + '.')

friends = ['phil', 'sarah']

for name in favorite_languages:
    print(name.title())
    if name in friends:
        print('Hi ' + str(name.title()) + ', I see your favorite language is ' +
        str(favorite_languages[name].title()) + '!') 

namesList = favorite_languages.keys()
print(namesList)

if 'erin' not in favorite_languages.keys():
    print('Erin, please take our poll!!')

setList = ['zhangsan', 'lisi', 'wangwu', 'zhangsan']
sets = set(setList)

for item in sets:
    print(item)

alien_3 = {'color': 'green', 'points': 5}
alien_4 = {'color': 'blue', 'points': 10}
alien_5 = { 'color': 'red', 'points': 25}

aliens = [alien_3, alien_4, alien_5]

for alien in aliens:
    print(alien)

aliens = []

for alien_number in range(1, 30):
    new_alien = {'color': 'green', 'points': alien_number, 'speed': 'slow'}
    print(new_alien)
    aliens.append(new_alien)

print("Total number of aliens:" + str(len(aliens)))

for alien in aliens[0:3]:
    if alien['color'] == 'green':
        alien['color'] = 'yellow'
        alien['speed'] = 'medium'
        alien['points'] = 20

for alien in aliens[0:5]:
    print(alien)

print('----')

pizzas = {
    'crust': 'thick',
    'toppings': ['mushroom', 'extra cheese'],
}

print("You ordered a " + pizzas['crust'] + " with the following toppings:")

for topping in pizzas['toppings']:
    print('\t' + topping)

favorite_languages = {
    'jen': ['python', 'ruby'],
    'sarah': ['c'],
    'edward': ['ruby', 'go'],
    'phil': ['python', 'haskell']
}

for name, language in favorite_languages.items():
    print('\n'+ str(name.title()) + "'s favorite language are: ")
    for lang in language:
        print('\t' + str(lang.title()))